{extend name="public/base"/}
{block name="style"}
    <link rel="stylesheet" href="/public/novelv2/css/templete/common.css">
    <link rel="stylesheet" href="/public/novelv2/pluginIn/Icon/iconfont.css">
    <script src="/public/novelv2/pluginIn/Icon/iconfont.js"></script>
    <link rel="stylesheet" href="/public/novelv2/pluginIn/icon3/iconfont.css">
    <script src="/public/novelv2/pluginIn/icon3/iconfont.js"></script>
    <link rel="stylesheet" href="/public/novelv2/pluginIn/swiper/dist/css/swiper.min.css">
    <link rel="stylesheet" href="/public/novelv2/css/pagecss/index.css">
    <link rel="stylesheet" href="/public/novelv2/css/templete/aside.css">
    <!-- 分页 -->
    <link rel="stylesheet" href="/public/novelv2/css/templete/pager.css">

    <link rel="stylesheet" href="/public/novelv2/css/pagecss/detail.css">
	<script src="/public/novelv2/js/templete/index.js"></script>
	<script src="/public/novelv2/pluginIn/webMain.js"></script>
	<script src="/public/novelv2/pluginIn/Swiper4/js/swiper.min.js"></script>
	<script src="/public/cartoon/js/layer.js"></script>
	<script>

		

		$('.head-login').click(function () {
			$('.no-login-ways').show()
		})
		$('.no-login-ways .close').click(function () {
			$('.no-login-ways').hide()
		})

		function loginRegist(obj) {
			obj.find('.loregbtn span').each(function (index, item) {
				$(this).click(function () {
					obj.find('.loregbtn span').removeClass('onclick').addClass('noclick')
					$(this).removeClass('noclick').addClass('onclick')
					obj.find('.inputBox').hide()
					obj.find('.inputBox').eq(index).show()
				})
			})
		}

		loginRegist($('.no-login-ways'))


		$('.user').click(function () {
			$('.has-login-back').toggle(500)
		});

		$('.no-login-ways .register input').focus(function () {
			$('.submit').removeClass('btnInit').addClass('btnActive')
		})
	</script>
	<style>
	.titleColor{position:relative;}
	.titleColor img{width:25px;height:20px;position:absolute;top:-5px;}
	</style>

{/block}
{block name="body"}
{include file="public/header" /}
	<div class="content widthWrap detailWrap">
        <div class="index-section">
            <!-- 左侧内容区 -->
            <div class="common-section-left fl ">
                <p class='pageMark'><a href='/'>首页</a><span>></span><a href='/books?channel={$channel}&cate={$category_id}'> {$category}</a><span>></span>{$title}</p>
                <!-- 书本列表 -->
                <div class='commom-description fl'>
                    <a href='/chapter/read/{$bookid}/{$previd}' class='Scover'>
                        <img class='largeImageSize' src='{empty name="cover"}/public/novel/images/default.jpg{else /}{$cover}{/empty}' alt=''></a>
                    <div class='des-right'>
                        <p class='titlelable'>
                            <a class='booktitleSize titlecolor texthide title'>{$title}</a>
                        </p>

                        <p class='d-author listcolor texthide'>
                            <a class='author ' href='JavaScript:;'>
                                <img src='/public/novelv2/img/index/home-icon-author.png' alt=''>{$author}</a><i>|</i><a href='/books?channel={$channel}&cate={$category_id}'>{$category}</a><i>|</i><a href='/books?channel={$channel}&cate={$category_id}&fullflag={$fullflag}'>{$fullflag==1?"已完结":"连载中"}</a><i>|</i><a >{$size}字</a><i>|</i><a >{$allvisit}次点击</a>
                        </p>

                        <p class='authorSize neweast'><a class='titleColor' href='javacript:void(0);' onclick="goread({if $chapter.isvip==1}true{else}false{/if}, {$chapter.saleprice}, '{:url('index/chapter/read',['bookid'=>$bookid,'chapterid'=>$chapter['id']])}')">最新：{$chapter.chaptername} {if $chapter.isvip==1}<img src="/public/novelv2/img/index/nover-icon-VIP.png" alt="">{/if}</a></p>

                        <p class='CS-descript authorSize listcolor'>　　{$chapter.content}...</p>

                        <div class='btn-group'>
                            <a class='beginReadbtn fl' style="color:#fff" href='{empty name="previd"}javascript:layer.msg("此作品无章节",{icon: 2});{else /}/chapter/read/{$bookid}/{$previd}{/empty}'>免费试读</a>
                            <a class='bookcasebtn fl' data='54'>{if $bookcase}√已加入书架{else}加入书架{/if}</a>
                             
                        </div>                      

                    </div>
                    <div class='phoneEnter' id='code' style='padding-left:12.5px'>                   

                    </div>
                    <div class='tips'>
                        <i>*</i><span>注：《{$title}》为网站作者“{$author}”所著虚构作品，不涉及任何真实人物、事件等，请勿将杜撰作品与现实挂钩。{$Think.config.web_site_title}支持第三方腾讯QQ、微信一键登录，实现极简登陆体验。登陆后可发言、投票、打赏等。</span>
                    </div>
                </div>

                <!-- 作品信息+作品目录+作品讨论区 -->
                <div class="web-titleTab">
                    <a class="activeTab message">作品信息</a><span>|</span><a class="message" id='PRODUCTDIRECTORY'>作品目录</a><span>|</span><a class="discuss">作品讨论区</a>
                </div>

                <!-- 作品信息+作品讨论区 -->
                <div class="production producct-Message">
                    <!-- 描述 -->
                    <p class="listcolor descrition">
                        {$intro}……
                    </p>
                    <!-- 打赏 -->
                    <div class="reward">
                        <div class="reward-left">
                            <p class="commonTitle">

                                <span class="titles titleColor">打赏</span><span class="num">({$sumbonus|default=0})</span>
                            </p>
                            <ul class="giftList">
								{volist name="bonusconfig" id="vo"}
                                <li>
                                    <img src='{$vo.imgfile}' alt=''><br>
                                    <span class='milinum'>{$vo.price}</span><span>{$vo.caption}</span>
                                </li>
								{/volist}
                            </ul>
                        </div>
                    </div>

                    <!-- 猜你喜欢 -->
                    <div class="Guesslike">
                        <p class="commonTitle">

                            <span class="titles titlecolor">猜你喜欢</span>
                            <span class="refresh titlecolor" onclick="refreshData();">
                                <img src="/public/novelv2/img/index/read-icon-refresh.png" alt="">换一换</span>
                        </p>
                        <div class="booklist-top Prerelease" id="BookList">
                        </div>
                    </div>

                    <!-- 作品讨论区 -->
                    <a class="discussArea" name='DISCUSS' id='DISCUSS'>
                        <p class="commonTitle">

                            <span class="titles titlecolor">作品讨论区</span>
                            <span class="num">({$review_count}条)</span>
                        </p>
                        <!-- 评论框 -->
                        <textarea class="discussWord wordBox" id="writecomment"></textarea>
                        <button class="writeBtn fr writeComent">写评论</button>
                        <!-- 评论-回复区 -->

                        
						{empty name="$review"}
							<!-- 无数据 -->
							<div class="no-datas">
								<img src="/public/novelv2/img/index/nover-no-write.png" alt="">
								<p class="listcolor">暂无评论，快去写第一条吧~</p>
							</div>
						{else /}
						 <!-- 有数据 -->
                        <div class="discuss-answer">
                            <ul class="main-discuss" id="comment">
								{volist name="review" id="vo"}
                                <li data-id='{$vo.id}'>
                                    <p class='discussant-name'>
                                        <img src='{$vo.avatar}' alt=''><span class='name'></span><span class='toTop'></span>
                                    </p>
                                    <p class='main-answer'>{$vo.content}</p>
                                    <p class='timeReans'>
                                        <span>{$vo.create_time}</span><span class='backAnswer backAnswerinit'>回复</span>
                                    </p>
                                    <!-- 回复内容 -->
                                    <div class='reMarkContent'>                                        
                                        <ol>
										{volist name="vo.replies" id="voo"}
										<li><p class='re-markName'></p><p class='remarkDetail'>{$voo.content}</p></li>
										{/volist}
										</ol>
                                        <p class='clickColor' style='display: none'>展开</p>
                                    </div>

                                </li>
								{/volist}
                            </ul>
                            <!-- <p class="lookMore">查看更多评论</p> -->
                            <!-- 分页 -->
                            <div class="paginationWrap" style="text-align: right" id="paginationWrap1">
                                <ul class="pagination" id="page">
                                </ul>
                                <div class="pageJump">

                                    <input type="text" />
                                    <span>页</span>
                                    <button type="button" class="button">GO</button>
                                </div>
                            </div>
                        </div>
						{/empty}

                        
                        
                    </a>
                </div>

                <!-- +{$randomStr} 作品目录 -->
                <div class="{$randomStr} production product-Directory">
                    <ul class="{$randomStr} dataList {$randomStr}" id="chapter">
						{volist name="chapterlist" id="vo" key="k"}
							
							<li {if $k%2!=0}class='mg {if $vo.articleid == $bookid}hasReading{/if}'{/if}><a href='javacript:void(0);' onclick="goread({if $vo.isvip==1}true{else}false{/if}, {$vo.saleprice}, '/chapter/read/{$vo.articleid}/{$vo.id}')">{if $vo.isvip==1}<img src="/public/novelv2/img/index/nover-icon-VIP.png" alt="">{/if}<span class='charpterlist'>{$vo.chaptername}</span><span class='aboutdate'>{$vo.update_time|date='Y-m-d',###}</span></a></li> 
						{/volist}
                    </ul>
                    <!-- <p class="lookMore">加载更多目录</p> -->
                    <!-- 分页 -->
                    <div class="paginationWrap" style="text-align: right" id="paginationWrap2">
                        <ul class="pagination" id="page1">
                        </ul>
                        <div class="pageJump">

                            <input type="text" />
                            <span>页</span>
                            <button type="button" class="button">GO</button>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 右侧 -->
            <div class="thirdRight fr aside">
                <div class='section-right right-item authorMes'><p class='Headforms'>
                        <img src='{$works_author}' alt=''><br>
                        {$author}
                    </p>
                    <ol>
                        <li><a href='javascript:;'>
                            <p>
                                <img src='/public/novelv2/img/index/nover-icon-works.png' alt=''><br>
                                <span class='listcolor'>作品总数</span>
                            </p>
                            <span>{$works_count}</span>
                        </a></li>
                        <li><a href='javascript:;'>
                            <p>
                                <img src='/public/novelv2/img/index/nover-icon-collection.png' alt=''><br>
                                <span class='listcolor'>作者等级</span>
                            </p>
                            <span>已签约</span>
                        </a></li>
                        <li><a href='javascript:;'>
                            <p>
                                <img src='/public/novelv2/img/index/nover-icon-time.png' alt=''><br>
                                <span class='listcolor'>驻站天数</span>
                            </p>
                            <span>{$works_days}</span>
                        </a></li>
                    </ol>
                    <p class='swiperTitle'>TA的作品</p>

                    <!-- 小轮播 -->
                    <div class='swiper-container'>
                        <div class='swiper-wrapper'>
							{volist name="works_list" id="vo"}
                            <div class='swiper-slide'>
                                <div>
                                    <a href='{:url('index/books/index',['id'=>$vo.id])}' class='book-online'>
                                        <img src='{empty name="vo.cover"}/public/novel/images/default.jpg{else /}{$vo.cover}{/empty}' alt=''></a>
                                    <p>
                                        <a class='title' href='{:url('index/books/index',['id'=>$vo.id])}'>{$vo.title}</a>
                                        <span class='text'>{$vo.intro|msubstr=0,40,'utf-8',true}
</span>
                                    </p>
                                </div>	
                            </div>
							{/volist}
                        </div>      
                        <div class='swiper-button-prev'></div>
                        <div class='swiper-button-next'></div>
                    </div></div>
                <div class="section-right right-item web-bookList">
                    <div class="side-title">
                        <p class="">小说推荐</p>
                    </div>
                    <ul id="BridRec1_femaleRec" class="side-bookList">
						{volist name="reviewtop" id="vo" key="k"}
						{if $k==1}
						<li class=firstLI'>
							<div class='side-book-des'>
								<a class='bookcover' href='{:url('index/books/index',['id'=>$vo.id])}'>
									<img src='{empty name="vo.cover"}/public/novel/images/default.jpg{else /}{$vo.cover}{/empty}' alt=''></a>
								<div class='tit-authr-des'>
									<a href='{:url('index/books/index',['id'=>$vo.id])}' class='title'>{$vo.title}</a>
									<a href='{:url('index/books/index',['id'=>$vo.id])}' class='author'>{$vo.author}</a>
									<p class='des'>{$vo.intro}……</p>
								</div>
							</div>
						</li> 
						{else/}
						<li class=''>
							<span class='circle'></span>
							<a href='{:url('index/books/index',['id'=>$vo.id])}' class='type'>【{$vo.category}】</a>
							<a href='{:url('index/books/index',['id'=>$vo.id])}' class='side-book-name'>{$vo.title}</a>
						</li>
						{/if}
						{/volist}
					</ul>

                </div>
            </div>
        </div>
    </div>
	 <!-- 打赏弹窗 -->
    <div class="spareMask">
        <div class="mask"></div>
        <div class="giving">
            <img class="close" src="/public/novelv2/img/index/read-button-close.png" alt="">
            <div class="gift">
                <ul>
				{volist name="bonusconfig" id="vo"}
                    <li data-text='{$vo.desc}' data-count='{$vo.price}' data-name='{$vo.caption}'>
                        <img class='giftInit' src='{$vo.imgfile}' alt='' data-id='{$key}'>
                    </li>
				{/volist}
                </ul>
                <p class="mineAcount">
                    <img src="{$avatar}" alt=""><span>我的余额：{$egold}阅币</span>
                </p>
                <p class="giveNum">
                    <span>打赏数量：</span><input type="text" class="giftnum" id="giftnum" value="1" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();"><span id="popname"></span><span class="fr totalNum"><i>10000</i>阅币</span>
                </p>
                <textarea class="giveWord" id="giveWord"></textarea>
                <button class="writeBtn fr sendGift">赠送</button>
            </div>
        </div>
    </div>

{block name="include"}{include file="public:footer" /}{/block}    
{/block}
{block name="script"}
<script src='/public/novelv2/js/templete/index.js'></script>
<script src='/public/novelv2/js/templete/pager.js'></script>
<script src="/public/novelv2/pluginIn/swiper/dist/js/swiper.min.js"></script>
<script src='/public/novelv2/js/templete/pager.js'></script>
<script src='/public/novelv2/js/jquery.qrcode.min.js'></script>
<script>
    var urls=window.location.href;
    urls=urls.split("-");
	var articleid = {$bookid};
	var channel = {$channel};
	var total = {$chapters/20|ceil};
	//var is_login = {if $Think.session.user_auth.uid>0}1{else/}0{/if};
    var egold = {$egold};

    function goread(vip, saleprice, url){
        if(vip&&is_login==0){
            $.loginBox(url);
            return false;
        }else{
			window.location.href = url;
		}
    }

    if(urls.length>1)
    {
        $('.web-titleTab .message').removeClass('activeTab');
        $('.web-titleTab .message').eq(1).addClass('activeTab');
        $('.production').hide()
        $('.production').eq(1).show()
    }

    var NovelID = $("#h_novelid").val()
    //订购全本
    $("#ordernovel").click(function () {
        if(this.innerHTML != "已订购")
        {
            var ifLogin = $('#ifLogin').attr("name")
            var IfEnough = $('#IfEnough').attr("name")
            var NovelTitle = $('#NovelTitle').attr("name")
            var UserBalance = $('#UserBalance').attr("name")
            var NovelFee = $('#NovelFee').attr("name")
            var FeeName = $('#FeeName').attr("name")

            if (ifLogin == "True") {
                if (IfEnough == "True") {
                    buyBook(0,FeeName,'订购全本', NovelTitle, '', '全本', NovelFee, UserBalance, NovelFee - UserBalance, '', '', '', '', '', NovelID);
                }
                else
                    buyBook(0,FeeName,'订购全本余额不足', NovelTitle, '', '全本', NovelFee, UserBalance, NovelFee - UserBalance, '', '', '', '', '', NovelID);
            }
            else
                $('.no-login-ways').show();
        }
    });

    var WapWebsite = $('#WapWebsite').attr("name")
    $("#code").qrcode({
        render: "table", //table方式
        width: 120, //宽度
        height:120, //高度
        text: WapWebsite+NovelID //任意内容
    });
    //加入书架和取消加入书架
    $(".bookcasebtn").click(function () {
        var obj = $(this);
		if (is_login==0)
		{
			$.loginBox();
			return;
		}
		
        if ($(this).attr('data') == null || $(this).attr('data') == "") {
            return;
        }
        if (this.innerHTML == "加入书架") {
            //修改div的内容
            $.ajax({
                url: "/book/bookcase",
                type: "post",
                data : {'articleid':articleid},
				dataType:'json',
                success: function (json) {
                    if (json.code==1) {
                        obj[0].innerHTML = "√已加入书架";
					}else if (json.code==2) {
						$.loginBox();
						return;
                    } else {
                        obj[0].innerHTML = json.msg;
                    }
                }
            });
        } else {
            $.ajax({
                url: "/book/bookcase",
                type: "post",
				dataType:'json',
                data : {'articleid':articleid},
                success: function (json) {
                    if (json.code==1) {
                        obj[0].innerHTML  = '加入书架';
                   	}else if (json.code==2) {
						$.loginBox();
						return;
                    } else {
                        obj[0].innerHTML = json.msg;
                    }
                }
            });
        }
    });

    $(function () {
        refreshData();
    });

    function refreshData() {
        $.get("{:url('books/GetData')}?Action=GetNewBook", function (result) {
            $("#BookList").html(result);
        });
    }

    $(".writeComent").click(function () {
        
        if (is_login == 1) {
            var message = $("#writecomment").val();
            if (message == "")
                showExchange("提示","请填写评论信息","")
            else {
                $.ajax({
                    url: "/book/commit",
                    type: "post",
					dataType: 'json',
					data : {'articleid':articleid,'content':message},
                    success: function (json) {
						if(json.code==1){
                			location.reload();
						}else{
							showExchange("提示","当前版块无法评论","")
						}
                    }
                });
            }
        }
        else
            $.loginBox();
    });

    $(document).on('click', '.answerBtn', function () {
       
        if (is_login == 1) {
            var message = $("#replycontent").val();
            var commentid = $(this).parents('li').attr('data-id');

            if (message == "")
                showExchange("提示","请填写回复信息","")
            else {
                $.ajax({
                    url: "/book/commit",
                    type: "post",
					dataType: 'json',
					data : {'articleid':articleid, 'reviewid':commentid, 'content':message},
                    success: function (json) {
                        if(json.code==1){
							layer.msg(json.msg, {icon: 1});
							setTimeout(function () {
								location.reload();
							}, 2000)
						}else{
							showExchange("提示","当前版块无法评论","")
						}
                    }
                });
            }
        }
        else
            $.loginBox();
    });

    // 打赏
    $(".sendGift").click(function () {
        if ($('#giftnum').val() < 1) {
            showExchange("提示","太小气了","")
        } else {
            $.ajax({
                url: "/book/bookbonus",
                type: "post",
				dataType: 'json',
				data : {'articleid':articleid,'actname':$('.giftChoose').attr('data-id'),'num':$("#giftnum").val()},
                success: function (json) {
					if(json.code==1){
						layer.msg(json.msg, {icon: 1});
	            		setTimeout(function () {
							location.reload();
						}, 2000)
					}else if(json.code==2){
						layer.msg(json.msg, {icon: 2});
					}else{
						layer.msg(json.msg, {icon: 2});
						setTimeout(function () {
								location.href = "/pay/index";
						}, 2000)
					}
                }
            });
        }

    });

    var swiper = new Swiper('.swiper-container', {
        spaceBetween: 30,
        hashNavigation: {
            watchState: true,
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true,
        },
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
    });

    textmore('.detailWrap .common-section-left .CS-descript', 120)
    textmore('.detailWrap .aside .CS-descript', 20)
    var i=0;

    if(i<=1){
        $('#paginationWrap1').hide()
    }else{
        function RefreshDataPage(index){
            $.ajax({
                url: "data/GetData.aspx",
                type: "post",
                data: { Module: " Book_Detail", Action: "DetailComment", Index: index,NovelId:$("#h_novelid").val()},
                success: function (data) {
                    $("#comment").html(data);
                }
            });
        }
        Page({
            num: i,				//页码数
            startnum: 1,				//指定页码
            elem: $('#page'),		//指定的元素
            callback: function (n) {	//回调函数
                RefreshDataPage(n);
            }
        });
    }

   

    if(total<=1){
        $('#paginationWrap2').hide()
    }else{
        function RefreshDataPage2(index){
            $.ajax({
                url: "{:url('books/GetData')}",
                type: "post",
                data: {Action: "DetailChapter", page: index,articleid:articleid},
                success: function (data) {
                    $("#chapter").html(data);
                }
            });
        }
        Page({
            num: total,				//页码数
            startnum: 1,				//指定页码
            elem: $('#page1'),		//指定的元素
            callback: function (n) {	//回调函数
				console.log(n);
                RefreshDataPage2(n);
            }
        });
    }

    var _remark = $('<div class="answerBox"><textarea class="answerWord  wordBox" id="replycontent"></textarea> <button class="answerBtn">回复</button></div>');
    $(document).on('click', '.backAnswer', function () {
        _remark.find("textarea").val("");
        if (!$(this).hasClass("backAnswerActive")) {
            $('.backAnswer').removeClass('backAnswerActive').addClass('backAnswerinit')
            $(this).removeClass('backAnswerinit').addClass('backAnswerActive')
            _remark.insertBefore($(this).parents('li').find(".reMarkContent"));
        } else {
            $('.backAnswer').removeClass('backAnswerActive').addClass('backAnswerinit')
            _remark.remove();
        }
    })

    $(document).on('click', '.clickColor', function () {
        if ($(this).text() == "展开") {
            $(this).text("收缩").prev().find("li").show();
        } else {
            var li = $(this).text("展开").prev().find("li");
            li.each(function (i, o) {
                if (i >= 4) {
                    $(this).hide();
                }
            });
        }

    })

    $('.detailWrap .discuss').click(function(){
        document.getElementById('DISCUSS').scrollIntoView()
    })
	$(function(){
		$('.reward-left ul li').each(function (index, item) {
			
			$(this).click(function () {
				if (is_login==1) {
					$('.spareMask').show()
					$('.gift ul li img').removeClass('giftChoose').addClass('giftInit')
					$('.gift ul li').eq(index).find('img').removeClass('giftInit').addClass('giftChoose')
					$('.gift .giveWord').val($('.gift ul li').eq(index).data('text'))
					var miliNum = $('.gift ul li').eq(index).data('count')
					$('.giveNum i').text($('.giftnum').val() * miliNum)
				}
				else
					$.loginBox();
			})
		})
		//$('.reward-left ul li').click(function () {
		//    $('.spareMask').show()
		//})

		$('.close').click(function () {
			$('.spareMask').hide()
			$('.giftnum').val(1)
		})
		$('.sendGift').click(function () {
			// $('.spareMask').hide()
			// $('.giftnum').val(1)
		})

		$('.giveNum input').keyup(function () {
			var choose = $('.giftChoose').parent('li').data('count');
			var valu = $(this).val()
			$('.giveNum i').text(choose * valu)
		})

		$('.gift ul li').each(function (index, item) {
			$(this).click(function () {
				$('.gift ul li img').removeClass('giftChoose').addClass('giftInit')
				$(this).find('img').removeClass('giftInit').addClass('giftChoose')
				$('.totalNum i').text($(this).data('count'))
				$('.gift .giveWord').val($(this).data('text'))
				$('.giftnum').val(1)
			})
		})
	})
</script>
{/block}